home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / Xteq X-Setup / xqdcXSP-Setup-EN.exe / {app} / plugins / XQ Mozilla 2.xpl < prev    next >
Text File  |  2002-09-24  |  4KB  |  91 lines

  1. "FILE"="Xteq Systems X-Setup Plugin 6.0"
  2. "TYPE"="6"
  3. "COUNT"="1"
  4. "UIPATH"="Internet\Mozilla"
  5. "NAME"="Miscellaneous Options"
  6. "VERSION"="1.0"
  7. "LANGUAGE"="VBScript"
  8. "TEXT 1"="Show About screen as dialog"
  9. "DESCRIPTION 1"="Option #1: When you go to Help > About in Mozilla, a new window is opened. With this enabled, it will show a tabbed dialog instead."
  10. "DESCRIPTION 2"="NOTE: This will affect all users of Mozilla on this computer."
  11. "DESCRIPTION 3"="Mozilla is free, open source web browser available from http://www.mozilla.org/ ."
  12. "AUTHOR"="Xteq Systems (Neil R. Turner)"
  13. "CONTACTURL"="http://www.xteq.com"
  14. "COPYRIGHT"="Copyright ⌐ Xteq Systems - All Rights Reserved"
  15. "COMMENT 1"="Rules of programming #46346: Never write plugins with a hangover."
  16.  
  17. ' Neil's attempt at creating a Mozilla plug-in for X-Setup. As you can see, it's a little
  18. ' complicated due to the way Mozilla stores its settings (ie in a completely non-standard
  19. ' format... so much for a standards compliance, eh?), so that's why the code is slightly
  20. ' more sloppy then usual. But it works. I think.
  21. ' Feel free to copy code elements for use in other Mozilla/Netscape plugins.
  22. sP="HKCU\Software\mozilla.org\Mozilla\"
  23. sV1="CurrentVersion"
  24. sV2="\Main\Install Directory"
  25.  
  26. Sub Plugin_Initialize
  27.  ' To find out where the Mozilla keys are stored, we have to go get the version number.
  28.  MozVer=RegReadValue(sP&sV1)
  29.  if IsEmpty(MozVer)=true then
  30.   Call Disable()
  31.  else
  32.  ' This tells us where Mozilla is installed, so that we can open the preferences files.
  33.   InsPath=RegReadValue(sP&MozVer&sV2)
  34.  end if
  35.  
  36.  ' Open all.js, which seems to be the main preference file.
  37.  Call TxtOpen(InsPath&"defaults\pref\all.js")
  38.  
  39.  ' Because we repeat a rather longwinded peace of code to get each setting, we use a SUB,
  40.  ' and provide it with the name of the value and what we would expect it to say if it was
  41.  ' on - for some reason Mozilla likes to put loads of spaces in, thus requiring more code.
  42.  ' It makes it easier to read, but from an X-Setup point of view, it's annoying. Grrrrrrr.
  43.  Call Build_UI("pref(""browser.show_about_as_stupid_modal_window"","," true);",1)
  44. End Sub
  45.  
  46. Sub Build_UI(Pref,Setting,Num)
  47.  i=TxtFindLine(Pref,false)
  48.  if i>0 then
  49.   s=TxtGetLine(i)
  50.   i=InStr(s,",") ' We're only interested in the stuff after the comma, so we get rid of the left hand side.
  51.   s=Right(s,len(s)-i)
  52.   if s=Setting then ' If what we've retrieved is the same as what we were expecting, then we set the UI elephant to true.
  53.    Call SetUIElement(Num,true)
  54.   end if
  55.  else
  56.   ' The prefs files may only be written on first launch or be corrupted, so if the item
  57.   ' can't be found, we let the user know.
  58.   Call MsgWarning("X-Setup encountered an error while trying to retrieve the settings. This may be because you have not run Mozilla yet, or the preferences are corrupted. Please run Mozilla, or reinstall it.")
  59.   Call Disable()
  60.  end if
  61. End Sub
  62.  
  63. Sub Plugin_Apply(ElementIndex,ElementSubIndex)
  64.  ' Yup, we need this again... Though since the plugin would already be disabled if it
  65.  ' didn't exist, we can skip a bit.
  66.  MozVer=RegReadValue(sP&sV1)
  67.  InsPath=RegReadValue(sP&MozVer&sV2)
  68.  
  69.  Call DoStuff("pref(""browser.show_about_as_stupid_modal_window"","," true);","  false);",1)
  70.  
  71.  
  72.  Call TxtSave()
  73. End Sub
  74.  
  75. Sub DoStuff(Pref,Enabled,Disabled,Num)
  76.  ' Amazingly, the Apply SUB is smaller than the Initilise SUB. Is this a first in X-Setup?
  77.  s=GetUIElement(Num)
  78.  if s=true then
  79.   i=TxtFindLine(Pref,false)
  80.   Call TxtSetLine(i,Pref&Enabled)
  81.  else
  82.   i=TxtFindLine(Pref,false)
  83.   Call TxtSetLine(i,Pref&Disabled)
  84.  end if
  85. End Sub
  86.  
  87. Sub Plugin_Terminate
  88.  Call TxtClose()
  89. End Sub
  90.